home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / icon / packages.lha / packages / amiga / ame.zoo / ipd124.doc next >
Text File  |  1990-03-24  |  23KB  |  733 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                  Version 8 of Icon for the Amiga
  8.  
  9.                          Clinton Jeffery
  10.     Department of Computer Science, The University of Arizona
  11.  
  12.  
  13.  
  14.  
  15. 1.__Introduction
  16.  
  17.    This is an implementation of Version 8 of the Icon programming
  18. language for Amiga computers.
  19.  
  20.    This implementation is in the public domain and may be copied
  21. and used without restriction. Icon is distributed free of charge
  22. by the University of Arizona, except for the costs of media,
  23. documentation, handling and shipping. No warranties of any kind
  24. as to the correctness of this material or its suitability for any
  25. application are made or implied. The responsibility for the use
  26. of Icon rests entirely with the user.
  27.  
  28.  
  29. 2.__Documentation
  30.  
  31.    The basic reference for the Icon programming language is the
  32. book The Icon Programming Language by Ralph E. Griswold and Madge
  33. T. Griswold, Prentice-Hall, Inc., Englewood Cliffs, New Jersey,
  34. 1983.  313 pages,  ISBN 0-13-449777-5. $30.95.
  35.  
  36.    This book is available in many college bookstores or can be
  37. ordered through any bookstore that handles special orders or by
  38. telephone directly from Prentice-Hall: (201) 767-9520.  It also
  39. is available from the Icon Project at the Department of Computer
  40. Science at the University of Arizona.
  41.  
  42.    A brief overview of Icon is contained in technical report TR
  43. 90-6 [1] (tr90-6.doc on the distribution diskette). Features that
  44. have been added to Icon since the book was written are described
  45. in TR 90-1 [2] (tr90-1.doc on the distribution diskette). These
  46. technical reports, together with this document (ipd124.doc on the
  47. distribution diskette), provide enough information to write sim-
  48. ple Icon programs, but if you are going to use Icon seriously,
  49. you will need the book.  You may also find it useful to examine
  50. the sample programs located on the distribution diskette.
  51.  
  52.  
  53. 3.__Hardware_and_Software_Requirements
  54.  
  55.    This version was designed to run under V1.3 of the Amiga
  56. operating system software, and the rest of this document assumes
  57. you are using it.  Amiga Icon version 8 has not been tested at
  58. all under V1.1 or V1.2.  There is no fundamental reason it cannot
  59. be used with the older versions; if you want to run Icon with an
  60. older version of the operating system you may have problems if
  61.  
  62.  
  63.  
  64. IPD124                        - 1 -                March 22, 1990
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. Icon can't find a path to its executables or if you need to use
  74. environment variables.
  75.  
  76.    This version of Icon is command-line based.  It does not run
  77. under the workbench and does not have any support for Workbench
  78. icons or any of the special Amiga features at this time.  You
  79. should be able to use your choice of: the CLI (for older versions
  80. of AmigaDOS), the new AmigaShell, or some third party shell such
  81. as Matt Dillon's shell.
  82.  
  83.    This version does not run on 512K machines.  It was compiled
  84. and runs comfortably on a machine with 1 megabyte of memory (more
  85. is better).  A hard disk is also essential for any serious pro-
  86. gramming work.
  87.  
  88.    Since Icont and Iconx use the default system stack, they will
  89. not run if the stack is left at the default 4000 bytes AmigaDOS
  90. allocates for created windows.  Before running icont or iconx
  91. from a CLI or Shell, you should increase the stack size.  This is
  92. done by issuing a command such as
  93.  
  94.         stack 15000
  95.  
  96. to the CLI from which you are going to run Icon.  Icont and Iconx
  97. will halt with an error message if you try to run them with a
  98. stack size of less than 10000 bytes.  A larger stack size will
  99. allow larger programs to be compiled and to run successfully.
  100.  
  101.  
  102. 4.__Location_of_icont and iconx
  103.  
  104.    The Icon system naturally follows the standard AmigaDOS search
  105. path to find executable files. That is, it looks first in the
  106. current directory, then in the C: directory, and finally in any
  107. other directories that you have added to the search path by means
  108. of the PATH command.
  109.  
  110.    This means that you probably will want to place your icont and
  111. iconx commands in your C: directory if you have room there, or
  112. you can add the directory where the Icon binaries are located to
  113. your search path if you are running from the ICON: diskette.
  114.  
  115.    Note that the Icon interpreter iconx has the same name as one
  116. of the AmigaDOS utilities.  Care should be taken when locating
  117. Icon's iconx and setting the AmigaDOS search path; one can always
  118. rename Icon's iconx program to something else if the AmigaDOS
  119. iconx is needed.  The AmigaDOS iconx is usually invoked from the
  120. Workbench, so this should not be too much of a problem.
  121.  
  122.  
  123. 5.__Running_Icon
  124.  
  125.    To translate and link an Icon source program file named
  126. myfile.icn first you must add Icon8.0:c to your path (or copy the
  127.  
  128.  
  129.  
  130. IPD124                        - 2 -                March 22, 1990
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139. executables to some directory where AmigaDOS can find them), and
  140. then type
  141.  
  142.         icont myfile
  143.  
  144. which translates and links myfile.icn and produces the file named
  145. myfile. You can then execute this by typing
  146.  
  147.         iconx myfile
  148.  
  149. This can be done all in one step as
  150.  
  151.         icont myfile -x
  152.  
  153.  
  154.    The usual standard input and standard output redirection is
  155. supported by the CLI, but note that the AmigaDOS standard is for
  156. the redirection to be given before the other arguments, thus:
  157.  
  158.         iconx <infile >outfile myprogram  myarg1 myarg2 ...
  159.  
  160. If the redirection arguments are not given immediately following
  161. the iconx, they do not work.
  162.  
  163.    It is not possible to redirect the standard error output in
  164. this version but it is possible to combine the standard error
  165. output with the standard output by using the command line switch
  166. -e - as follows:
  167.  
  168.         iconx >outfile -e - myprogram args args ...
  169.  
  170. All the output from the program including error messages is sent
  171. to outfile. Note that it is necessary to type the dash (-) fol-
  172. lowing the switch. Just typing -e has no effect; you must type -e
  173. -.  This switch is only allowed on the iconx command. It does
  174. work on the icont command.
  175.  
  176.  
  177. 6.__Testing_the_Installation
  178.  
  179.    There are a few programs on the distribution diskette that may
  180. be used for testing the installation and getting a feel for run-
  181. ning Icon.  The programs and appropriate data files are located
  182. in the samples directory.  Note that files containing Icon pro-
  183. grams must have the extension .icn. Such files should be plain
  184. text files (without line numbers or other extraneous informa-
  185. tion). The command processor icont produces an icode file that
  186. can be executed by iconx.  For example, an Icon program in the
  187. file prog.icn is translated and linked by
  188.  
  189.         icont prog
  190.  
  191. The result is an icode file (binary) with the name prog (with the
  192. extension removed).  This file can be run by
  193.  
  194.  
  195.  
  196. IPD124                        - 3 -                March 22, 1990
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.         iconx prog
  206.  
  207. Alternatively, icont can be instructed to execute the program
  208. after translating and linking by appending a -x to the command
  209. line, as in
  210.  
  211.         icont prog -x
  212.  
  213. In this case the file prog also is left and can be run subse-
  214. quently using iconx.
  215.  
  216.    Note that the icont  and iconx programs are executable binary
  217. files and, as such their locations can be discovered by the nor-
  218. mal AmigaDOS executable file path search mechanism. But the icode
  219. file produced by icont from the Icon source file is not a
  220. directly executable file. It essentially is a data file that is
  221. read by the Icon interpreter iconx. Therefore, the location of
  222. the icode file is not known to AmigaDOS. There is no path search
  223. for data files. So your icode file (prog in the above examples)
  224. must either be in the current directory, or you must specify its
  225. location by giving the drive or directory path as part of the
  226. filename.
  227.  
  228.    For example, if your current directory is RAM:, and you wish
  229. to run the Icon program prog.icn, which might be located in the
  230. directory df1:src, and you have placed icont in a location where
  231. AmigaDOS can find it, you would type
  232.  
  233.         icont df1:src/prog -x
  234.  
  235. In this case, the icode file prog would be left behind in ram:,
  236. which was your current directory, after it has been run.  You
  237. would then be able to run prog again by simply typing
  238.  
  239.         iconx prog
  240.  
  241. The sample programs are:
  242.  
  243.      hello.icn     This program prints the Icon version number,
  244.                    time, and date. Run this test as
  245.  
  246.                            icont hello
  247.                            iconx hello
  248.  
  249.                    Note that this can be done in one step with
  250.  
  251.                            icont hello -x
  252.  
  253.  
  254.      cross.icn     This program prints all the ways that two
  255.                    words intersect in a common character. The
  256.                    file cross.dat contains typical data. Run this
  257.                    test as
  258.  
  259.  
  260.  
  261.  
  262. IPD124                        - 4 -                March 22, 1990
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.                            icont <cross.dat cross -x
  272.  
  273.  
  274.      meander.icn   This program prints the ``meandering strings''
  275.                    that contain all subsequences of a specified
  276.                    length from a given set of characters. Run
  277.                    this test as
  278.  
  279.                            icont <meander.dat meander -x
  280.  
  281.  
  282.      roman.icn     This program converts Arabic numerals to Roman
  283.                    numerals. Run this test as
  284.  
  285.                            icont roman -x
  286.  
  287.                    and provide some Arabic numbers from your con-
  288.                    sole.
  289.  
  290.      sieve.icn     This program produces prime numbers. Run this
  291.                    test as
  292.  
  293.                            icont <sieve.dat sieve -x
  294.  
  295.  
  296. If these tests work, your installation is probably correct and
  297. you should have a running version of Icon.
  298.  
  299.  
  300. 7.__Special_I/O
  301.  
  302.    This version supports the standard AmigaDOS device names as
  303. files.  Thus, to write directly to the printer from your Icon
  304. program do this:
  305.  
  306.         fd := open("PRT:","w")
  307.         write(fd,"this will appear on your printer")
  308.         close(fd)
  309.  
  310. The existing CLI window is used for standard i/o unless these are
  311. redirected from the command line.
  312.  
  313.    To use the CLI window for i/o when standard input or output
  314. has been redirected elsewhere, you can open it as file * as
  315. explained in the AmigaDOS manual, thus:
  316.  
  317.         tty := open("*","b")
  318.         line := read(tty)
  319.         write(tty,line)
  320.         close(tty)
  321.  
  322. You can also open additional CON: or RAW: windows as described in
  323. the AmigaDOS manual, thus:
  324.  
  325.  
  326.  
  327.  
  328. IPD124                        - 5 -                March 22, 1990
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.         con := open("CON:10/10/100/100/my window","b")
  338.         write(con,"This appears in a new window")
  339.         close(con)
  340.  
  341. Note that as soon as you close a special window it disappears.
  342.  
  343.    If you open a RAW: window for reading, notice that there is no
  344. echoing done for you and you must handle all the raw input as
  345. described in the AmigaDOS manual. RAW: i/o has not been exten-
  346. sively tested yet in this version, so it is possible that you may
  347. have problems. The AmigaDOS documentation is also notoriously
  348. misleading.
  349.  
  350.  
  351. 8.__More_on_Running_Icon
  352.  
  353.    For simple applications, the instructions for running Icon
  354. given in Section 6 may be adequate. The icont translator supports
  355. a variety of options that may be useful in special situations.
  356. There also are several aspects of execution that can be con-
  357. trolled with environment variables.  These are listed here. If
  358. you are new to Icon, you may wish to skip this section on the
  359. first reading but come back to it if you find the need for more
  360. control over the translation and execution of Icon programs.
  361.  
  362. 8.1__Arguments
  363.  
  364.    Arguments can be passed to the Icon program by appending them
  365. to the command line.  Such arguments are passed to the main pro-
  366. cedure as a list of strings.  For example,
  367.  
  368.         iconx prog text.dat log.dat
  369.  
  370. runs the icode file prog.icx, passing its main procedure a list
  371. of two strings, "text.dat" and "log.dat".  The program also can
  372. be translated and run with these arguments with a single command
  373. line by putting the arguments after the -x:
  374.  
  375.         icont prog -x text.dat log.dat
  376.  
  377. These arguments might be the names of files that prog.icn reads
  378. from and writes to. For example, the main procedure might begin
  379. as follows:
  380.  
  381.         procedure main(a)
  382.            in := open(a[1]) | stop("cannot open input file")
  383.            out := open(a[2],"w") | stop("cannot open output file")
  384.                        .
  385.                        .
  386.                        .
  387.  
  388. See also the information about the processing of command-line
  389. arguments given in Section 8.4.
  390.  
  391.  
  392.  
  393.  
  394. IPD124                        - 6 -                March 22, 1990
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403. 8.2__The_Translator
  404.  
  405.    The icont translator can accept several Icon source files at
  406. one time.  When several files are given, they are translated and
  407. combined into a single icode file whose name is derived from the
  408. name of the first file.  For example,
  409.  
  410.         icont prog1 prog2
  411.  
  412. translates the files prog1.icn and prog2.icn and produces one
  413. icode file, prog1.icx.
  414.  
  415.    A name other than the default one for the icode file produced
  416. by MiconfR can be specified by using the -o option, followed by
  417. the desired name. For example,
  418.  
  419.         icont -o probe.icx prog
  420.  
  421. produces the icode file named probe.icx rather than prog.icx.
  422.  
  423.    If the -c option is given to icont, the translator stops
  424. before producing an icode file and intermediate ``ucode'' files
  425. with the extensions .u1 and .u2 are left for future use (normally
  426. they are deleted).  For example,
  427.  
  428.         icont -c prog1
  429.  
  430. leaves prog1.u1 and prog1.u2, instead of producing prog1.icx.
  431. These ucode files can be used in a subsequent icont command by
  432. using the .u1 name. This saves translation time when the program
  433. is used again.  For example,
  434.  
  435.         icont prog2 prog1.u1
  436.  
  437. translates prog2.icn and combines the result with the ucode files
  438. from a previous translation of prog1.icn. Note that only the .u1
  439. name is given. The extension can be abbreviated to .u, as in
  440.  
  441.         icont prog2 prog1.u
  442.  
  443. Ucode files also can be added to a program using the link
  444. declaration in an Icon source program as described in [2].
  445.  
  446.    Icon source programs may be read from standard input.  The
  447. argument - signifies the use of standard input as a source file.
  448. In this case, the ucode files are named stdin.u1 and stdin.u2 and
  449. the icode file is named stdin.icx.
  450.  
  451.    The informative messages from the translator can be suppressed
  452. by using the -s option.  Normally, both informative messages and
  453. error messages are sent to standard error output.
  454.  
  455.    The -t option causes &trace to have an initial value of -1
  456. when the icode file is executed.  Normally, &trace has an initial
  457.  
  458.  
  459.  
  460. IPD124                        - 7 -                March 22, 1990
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469. value of 0.
  470.  
  471.    The option -u causes warning messages to be issued for unde-
  472. clared identifiers in the program.
  473.  
  474.    Icon has several tables related to the translation of pro-
  475. grams.  These tables are large enough for most programs, but
  476. translation is terminated with an error message, indicating the
  477. offending table, if there is not enough room.  If this happens,
  478. larger table sizes can be specified by using the -S option. This
  479. option has the form -S[cfgilnrstCFL]n, where the letter following
  480. the S specifies the table and n is the number of storage units to
  481. allocate for the table.
  482.  
  483.      c  constant table          100
  484.      f  field table             100
  485.      g  global symbol table     200
  486.      i  identifier table        500
  487.      l  local symbol table      100
  488.      n  line number table      1000
  489.      r  record table            100
  490.      s  string space          20000
  491.      t  tree space            15000
  492.      C  code buffer           15000
  493.      F  file names               10
  494.      L  labels                  500
  495.  
  496. The units depend on the table involved, but the default values
  497. can be used as guides for appropriate settings of -S options
  498. without knowing the units.  For example,
  499.  
  500.         icont -Sc200 -Sg600 prog
  501.  
  502. translates prog.icn with twice the constant table space and three
  503. times the global symbol table space that ordinarily would be pro-
  504. vided.
  505.  
  506. 8.3__Environment_Variables
  507.  
  508.    When an icode file is executed, several environment variables
  509. are examined to determine execution parameters.  The values
  510. assigned to these variables should be numbers.
  511.  
  512.    Environment variables are particularly useful in adjusting
  513. Icon's storage requirements. This may be necessary if your com-
  514. puter does not have enough memory to run programs that require an
  515. unusually large amount of data.  Particular care should be taken
  516. when changing default sizes: unreasonable values may cause Icon
  517. to malfunction.
  518.  
  519.    The following environment variables can be set to affect
  520. Icon's execution parameters. Their default values are listed in
  521. parentheses after the environment variable name:
  522.  
  523.  
  524.  
  525.  
  526. IPD124                        - 8 -                March 22, 1990
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.         TRACE (undefined).  This variable initializes the value
  536.      of &trace.  If this variable has a value, it overrides the
  537.      translation-time -t option.
  538.  
  539.         NOERRBUF (undefined).  If this variable is set, &errout
  540.      is not buffered.
  541.  
  542.         STRSIZE (65000). This variable determines the initial
  543.      size, in bytes, of the region in which strings are stored.
  544.  
  545.         HEAPSIZE (65000).  This variable determines the initial
  546.      size, in bytes, of the region in which Icon allocates lists,
  547.      tables, and other objects.
  548.  
  549.         COEXPSIZE (2000). This variable determines the size, in
  550.      32-bit words, of each co-expression block.
  551.  
  552.         MSTKSIZE (10000). This variable determines the size, in
  553.      words, of the main interpreter stack.
  554.  
  555.         QLSIZE (5000). This variable determines the size, in
  556.      bytes, of the region used by the garbage collector for
  557.      pointers to strings.
  558.  
  559.    The maximum region size that can be specified is 65000.
  560.  
  561.    The special variable CHECKBREAK is used only in the Amiga ver-
  562. sion of Icon.  If the line
  563.  
  564.         CHECKBREAK=1
  565.  
  566. appears in your environment file, you should be able to interrupt
  567. the execution of an Icon program by typing Control-C or Control-
  568. D.
  569.  
  570.    If this environment variable is not set, you may still be able
  571. to interrupt the program, but only if it is doing i/o.  Icon runs
  572. significantly slower when CHECKBREAK is set but it is useful when
  573. developing programs.
  574.  
  575.    An example of memory region resizing may be seen in the sample
  576. environment file SmallIconEnv.
  577.  
  578.  
  579. 9.__Impacts_for_Users_of_Older_Versions_of_Icon_for_the_Amiga
  580.  
  581.    Persons who have used Version 6 of Icon for the Amiga will
  582. find only a few changes in Version 8, most of which are upward
  583. compatible extensions.  In addition to the language enhancements
  584. present in Version 8, the primary change visible to users of Ver-
  585. sion 6 for the Amiga is the new environment variable mechanism.
  586. The old ``environment files'' are no longer used; instead the
  587. environment variable mechanism used by Aztec C 3.6a has been
  588. adopted.  A program called setenv is provided along with the
  589.  
  590.  
  591.  
  592. IPD124                        - 9 -                March 22, 1990
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601. Icont and Iconx executables for those of you without Aztec C.
  602. The command setenv foo returns the value of foo if there is any.
  603. The command setenv foo=bar sets the environment variable foo to
  604. the value bar.  Environment variables seem to work under Version
  605. 1.3 of AmigaDOS; they have not been tested under earlier versions
  606. of the operating system.
  607.  
  608.    Persons who have used Version 7.5 of Icon for the Amiga will
  609. be happy to hear that in addition to the mandatory stack size
  610. checks, Version 8 of Icont now allows code (such as ucode
  611. libraries) to be linked in from other directories in the correct
  612. fashion.
  613.  
  614.  
  615. 10.__Known_Bugs
  616.  
  617.    A list of known bugs in Icon itself is given in [2].  Known
  618. bugs that are specific to the Amiga implementation of Icon are:
  619.  
  620.      +  The atan2 function simply divides its first argument
  621.         by its second and calls atan.  If this division causes
  622.         overflow, the call to atan2 will produce incorrect
  623.         results.  This is due to the C compiler used to create
  624.         Amiga Icon Version 8.
  625.  
  626.      +  Floating-point numbers are occasionally printed rather
  627.         strangely.  In addition, floating-point numbers in this
  628.         implementation of Icon seem to have a smaller range of
  629.         legal values than in some other implementations of Icon.
  630.         This is due to the C compiler used to create Amiga Icon
  631.         Version 8.
  632.  
  633.      +  Specifying a directory name as an argument to Icont or
  634.         Iconx, or in a call to Icon's open() function, may cause
  635.         disaster.  The implementation does not check to see if
  636.         the file is a directory as it should.
  637.  
  638.  
  639. 11.__Reporting_Problems
  640.  
  641.    Problems with Amiga Icon should be noted on a trouble report
  642. form (trouble.frm on the distribution diskette) and sent to
  643.  
  644.         Icon Project
  645.         Department of Computer Science
  646.         Gould-Simpson Building
  647.         The University of Arizona
  648.         Tucson, AZ   85721
  649.         U.S.A.
  650.         (602) 621-4049
  651.         icon-project@cs.arizona.edu     (Internet)
  652.         ... {uunet, allegra, noao}!arizona!icon-project     (uucp)
  653.  
  654. If a program is involved, enclose it and any relevant data on a
  655. diskette.
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. IPD124                       - 10 -                March 22, 1990
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673. 12.__Registering_Copies_of_Icon
  674.  
  675.    If you received your copy of Version 8 of Icon for the Amiga
  676. directly from the Icon Project, it has been registered in your
  677. name and you will receive the Icon Newsletter without charge.
  678. This Newsletter contains information about new implementations,
  679. updates, programming techniques, and information of general
  680. interest about Icon.
  681.  
  682.    If you received your copy of Version 8 of Icon for the Amiga
  683. from another source, please fill out a registration form
  684. (regis.frm in the documents on the distribution diskette) and
  685. send it to the Icon Project at the address listed above. This
  686. entitles you to a free subscription to the Icon Newsletter and
  687. assure that you receive information about updates.
  688.  
  689. Acknowledgements
  690.  
  691.    The design and development of the Icon programming language
  692. was supported, in part, by the National Science Foundation under
  693. grants MCS75-01397, MCS79-03890, MCS81-01916, DCR-8320138, DCR-
  694. 8401831, and DCR-8502015.
  695.  
  696.    Many individuals contributed to the design and implementation
  697. of Icon. The principal ones are Cary Coutant, Dave Hanson, Tim
  698. Korb, Bill Mitchell, Janalee O'Bagy, Gregg Townsend, Ken Walker,
  699. and Steve Wampler.
  700.  
  701.    Rob McConeghy originally adapted Version 6 of Icon to run on
  702. the Amiga.  Much of the Version 8 configuration for the Amiga is
  703. based on his work.
  704.  
  705. References
  706.  
  707.  
  708. 1.   R. E. Griswold, An Overview of Version 8 of the Icon
  709.      Programming Language, The Univ. of Arizona Tech. Rep. 90-6,
  710.      1990.
  711.  
  712. 2.   R. E. Griswold, Version 8 of Icon, The Univ. of Arizona
  713.      Tech. Rep. 90-1, 1990.
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. IPD124                       - 11 -                March 22, 1990
  731.  
  732.  
  733.